package main

import (
	"context"
	"fmt"
	"github.com/micro/go-micro"
	"demo_v1/message"
	"github.com/micro/go-plugins/registry/consul"
)

func main(){
	//创建一个客户端微服务
	service := micro.NewService(
		micro.Name("service.client"),
		micro.Registry(consul.NewRegistry()),//将服务注册到consul服务注册发现组件(client端从consul处发现目标服务的信息ip,port)
		)
	//初始化option配置
	service.Init()

	//创建指定微服务客户端
	client := message.NewSetudenService("student-server",service.Client())
	//远程调用方法
	student,err := client.GetStudent(context.Background(),&message.StudentRequest{Name:"jimmy"})
	if err!=nil{
		panic(err.Error())
	}
	fmt.Println(*student)
}
